#ifndef NETWORK_H
#define NETWORK_H

#include <string>
#include "RakPeer.h"
#include "MessageIdentifiers.h"

using namespace RakNet;

class Network
{
    private:
        std::string ip;
        int port;
        bool connected;

        unsigned char packetIdentifier;
        Packet *packet;
        RakPeerInterface *client;
        unsigned char GetPacketIdentifier(Packet *p);

    public:
        Network();
        ~Network();

        bool connect(std::string destIP, int destPort);
        void disconnect();

        void receive_data();
        void send_message(const RakNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability);
};

enum GameMessages
{
    ID_PLAYER_JOIN = ID_USER_PACKET_ENUM,
    ID_PLAYER_PART,
    ID_PLAYER_UPDATE,
    ID_PLAYER_FLAG,
    ID_PLAYER_ATTACK,
    ID_NPC_SPAWN,
    ID_NPC_FLAG,
    ID_NPC_ATTACK,
    ID_ACCOUNT_CREATE,
    ID_ACCOUNT_CREATE_FAILED,
    ID_ACCOUNT_CREATE_OK,
    ID_ACCOUNT_LOGIN,
    ID_ACCOUNT_LOGIN_FAILED,
    ID_ACCOUNT_LOGIN_OK,
    ID_CHARACTER_INFO,
    ID_CHARACTER_CREATE,
    ID_CHARACTER_CREATE_FAILED,
    ID_CHARACTER_CREATE_OK
};

enum PlayerMessages
{
    ID_PLAYER_POS,
    ID_PLAYER_HP,
    ID_PLAYER_MP,
    ID_PLAYER_MAXHP,
    ID_PLAYER_MAXMP,
    ID_PLAYER_LVL
};

enum QuitMessages
{
    ID_QUIT_DISCONNECT,
    ID_QUIT_CONNECTION_LOST
};

#endif // NETWORK_H
